//
//  QualificationCertificationViewController.m
//  WHB_logist
//
//  Created by 徐国庆 on 15/12/7.
//  Copyright (c) 2015年 turing. All rights reserved.
//

#import "QualificationCertificationViewController.h"

@interface QualificationCertificationViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, strong)UITableView *tableView;
@property(nonatomic, strong)NSArray *array;

@end

@implementation QualificationCertificationViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.array = [NSArray arrayWithObjects:@"企业名称", @"营业执照副本", @"危险品经营许可证", @"组织机构代码", @"税证登记证", nil];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navtitle.text = @"资质认证";
    [self initWithView];
    
}

#pragma mark UITableViewDelegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *indentifer = @"qualificationCertificationCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifer];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifer];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = [self.array objectAtIndex:indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    
    if (indexPath.row < self.array.count - 1) {
        UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(-1, 44, kUIScreenWidth + 2, 10)];
        lineLabel.layer.borderWidth = 0.5;
        lineLabel.backgroundColor = [UIColor HexStrWithColor:@"F0F0F0"];
        lineLabel.layer.borderColor = [UIColor HexStrWithColor:@"d0d0d0"].CGColor;
        [cell.contentView addSubview:lineLabel];
    }
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == self.array.count - 1) {
        return 44;
    }
    return 54;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"资质认证");
}

#pragma mark 提交审核
- (void)footerButtonAction:(UIButton *)button{
    NSLog(@"提交审核");
}

- (UIView *)headerView{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, kNavHeight, kUIScreenWidth, 40)];
    
    UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kUIScreenWidth + 2, 40)];
    lineLabel.backgroundColor = [UIColor HexStrWithColor:@"FF8000"];
    lineLabel.text = @"审核状态:审核中，预计两个工作日完成";
    lineLabel.font = [UIFont systemFontOfSize:14];
    lineLabel.textColor = [UIColor whiteColor];
    lineLabel.textAlignment = 1;
    
    [view addSubview:lineLabel];
    
    return view;
}

- (UIView *)footerView{
    
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kUIScreenWidth, 40)];
    
    UIButton *footerButton = [UIButton buttonWithType:UIButtonTypeCustom];
    footerButton.frame = CGRectMake(10, 0, kUIScreenWidth - 20, 40);
    footerButton.layer.masksToBounds = YES;
    footerButton.layer.cornerRadius = 5;
    [footerButton setTitle:@"提交审核" forState:UIControlStateNormal];
    footerButton.backgroundColor = [UIColor HexStrWithColor:@"CE0000"];
    [footerButton addTarget:self action:@selector(footerButtonAction:) forControlEvents:UIControlEventTouchDown];
    [bottomView addSubview:footerButton];
    return bottomView;
}
- (void)initWithView{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kUIScreenWidth, kUIScreenHeight) style:UITableViewStyleGrouped];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.tableFooterView = [self footerView];
    self.tableView.tableHeaderView = [self headerView];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.scrollEnabled = NO;
    [self.view addSubview:self.tableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
